package leetcode1;

public class Day5 {
    //2418.按身高排序
    public String[] sortPeople(String[] names, int[] heights) {
        int n = heights.length;
        for(int i=0;i<n-1;i++) {
            for(int j=0;j<n-1-i;j++) {
                if(heights[j]<heights[j+1]) {
                    //交换
                    swap(names,j,j+1);
                    int tmp = heights[j];
                    heights[j]=heights[j+1];
                    heights[j+1]=tmp;
                }
            }
        }
        return names;
    }
    public void swap(String[] names,int i,int j) {
        String tmp = names[i];
        names[i]=names[j];
        names[j]=tmp;
    }
}
